<?php
class TeacherLogController  extends AdminBaseController {
	public function lists(){
		$where = $_GET;
		$data['teacher_id'] = isset($_REQUEST['teacher_id'])?$_REQUEST['teacher_id'] :$_SESSION['admin']['teacher_id'];
		if(!isset($_GET['start_time'])){
			$data['start_time'] = HttpServerManager::getTeacherLogServer()->getTeacherSalaryStartTime();
		}else{
			$data['start_time'] = $_GET['start_time'];
		}
		if(!isset($_GET['over_time'])){
			$data['over_time'] = HttpServerManager::getTeacherLogServer()->getTeacherSalaryEndTime(); 
		}else{
			$data['over_time'] = $_GET['over_time'];
		}
		
		if(isset($_GET['book_no'])){
			$data['book_no'] = $_GET['book_no'];
		}
		
		$where = array();
		$where['teacher_id'] = $data['teacher_id'];
		$where['book_no'] = $data['book_no'];
		
		if (!empty($data['start_time'])){
			$where['start_time'] = strtotime($data['start_time']);
		}
		if (!empty($data['over_time'])){
			$where['over_time'] =strtotime($data['over_time']);
		}
		
		$teacherLogList =  HttpServerManager::getTeacherLogServer()->pagingBookCourseLog($where);
		$teacherSumInfo =  HttpDaoManager::getTeacherLogDao()->getTeacherSumInfo($where);
		
		$data['sumIntegral'] =$teacherSumInfo['integral'];
		$data['sumMoney'] = $teacherSumInfo['money'];
		$teacherData = HttpDaoManager::getTeacherDao()->get($data['teacher_id']);
		
		$time_pair = Common::getTimesPairsArray();
		$book_course_pair = array();
				
		$list = array();
		$type = Common::_t('teacher_log_type');
		$class_status_pair = Common::_t('class_status');
		$book_teacher_class_pair = Common::_t('book_teacher_status');
		$book_user_status_pair = Common::_t('book_user_status');
		$week_list = Common::_t('week');
		$holiday_list = Common::_t('holiday');
		foreach ($teacherLogList['list'] as $v){
			$v['class_status_name'] = $class_status_pair[$v['class_status']];
			$v['teacher_status_name'] = $book_teacher_class_pair[$v['teacher_status']];
			$v['user_status_name'] = $book_user_status_pair[$v['user_status']];
			$v['book_course_time'] =  date('Y-m-d',$v['book_date']).'  '.$time_pair[$v['book_time']];
			$v['book_course_finish_time'] = date('Y-m-d H:i:s',$v['add_time']);
			$week = date("w",$v['book_date']);
			if($week==0||$week==6){
				$v['week_name'] = $week_list[$week];
			}else{
				$v['week_name'] = "";
			}
			$holiday_day =  date("m-d",$v['add_time']);
			if(in_array($holiday_day,$holiday_list)){
				$v['holiday_name'] = 'holiday';
			}else{
				$v['holiday_name'] = '';
			}

			$v['type'] = $type[$v['type']];
			$v['book_course_id'] = $v['id'];
			$list[]=$v;
		}
		$data['teacher_info'] = $teacherData;
		$data['list'] = $list;
		$data['holiday_list'] = $holiday_list;
		$data['page'] = $teacherLogList['page'];
		return $data;
	}
	
	public function reportLists(){
		$where = $_GET;
		if(!isset($_GET['start_time'])){
			$data['start_time'] = HttpServerManager::getTeacherLogServer()->getTeacherSalaryStartTime();
		}else{
			$data['start_time'] = $_GET['start_time'];
		}
		
		if(!isset($_GET['over_time'])){
			$data['over_time'] = HttpServerManager::getTeacherLogServer()->getTeacherSalaryEndTime(); 
		}else{
			$data['over_time'] = $_GET['over_time'];
		}
		
		$where = array();
		if (!empty($data['start_time'])){
			$where['start_time'] = strtotime($data['start_time']);
		}
		if (!empty($data['over_time'])){
			$where['over_time'] =strtotime($data['over_time']);
		}
		if (!empty($_GET['serial_number'])){
			$where['serial_number'] =$_GET['serial_number'];
			$data['serial_number'] = $_GET['serial_number'];
		}
		if (!empty($_GET['name'])){
			$where['name'] =$_GET['name'];
			$data['name'] = $_GET['name'];
		}
		if (!empty($_GET['real_education_experience'])){
			$where['real_education_experience'] =$_GET['real_education_experience'];
			$data['real_education_experience'] = $_GET['real_education_experience'];
		}
		
		$teacherLogList =  HttpServerManager::getTeacherLogServer()->pagingGroup($where);
		$teacherSumInfo = HttpDaoManager::getTeacherLogDao()->getSumGroupInfo($where);
		
		$list = array();
		$type = Common::_t('teacher_log_type');
		$class_status_pair = Common::_t('class_status');
		$book_teacher_class_pair = Common::_t('book_teacher_status');
		$book_user_status_pair = Common::_t('book_user_status');
		$sumIntegral = 0;
		$sumMoney = 0;
		foreach ($teacherLogList['list'] as $v){
			$list[] = $v;
		}
		$data['sumMoney'] = round($teacherSumInfo[0]['money']);
		$data['sumIntegral'] = round($teacherSumInfo[0]['integral']);

		$data['list'] = $list;
		$data['page'] = $teacherLogList['page'];
		
		$educationExperience = Common::_t('education_experience');
		$realEducationExperienceOption = page_modifier_options($educationExperience,getStr($data, 'real_education_experience'));
		$data['realEducationExperienceOption'] = $realEducationExperienceOption;
		return $data;
	}
}
?>